<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>JS数组</h1>
    <p>获取数组中大于或等于18的每个元素</p>
    <p id="demo"></p>
    <script>
        const ages = [12,55,26,17];
        document.querySelector("#demo").innerHTML = ages.filter(checkAdult);
        function checkAdult(age){
            return age>=18;
        }
    </script>
</body>
</html>